<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
    function sendGet() {
        const xmlHttp = new XMLHttpRequest()
        xmlHttp.open('GET', 'http://127.0.0.1:8080/api/index?age=18&sex=man', true)
        xmlHttp.send()
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState === 4) {
                if (xmlHttp.status === 200 && xmlHttp.status < 300) {
                    console.log(xmlHttp.response)
                    // result.innerHTML = xmlHttp.response
                } else {

                }
            }
        }
        console.log("get")
    }
    function sendPost() {
        const xmlHttp = new XMLHttpRequest()
        xmlHttp.open('POST', 'http://127.0.0.1:8080/api/user', true)
        xmlHttp.send()
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState === 4) {
                if (xmlHttp.status === 200 && xmlHttp.status < 300) {
                    console.log(xmlHttp.response)
                    // result.innerHTML = xmlHttp.response
                } else {

                }
            }
        }
        console.log("post")
    }
</script>

<body>
    <div id="btn1" onclick="sendGet()">get</div>
    <div id="btn2" onclick="sendPost()">post</div>
</body>


</html>